name: Torchinductor

on:
  workflow_run:
    workflows: ["Wheels"]
    types: [completed]

permissions: read-all

jobs:
  Runner-Preparation:
    runs-on: ubuntu-latest
    outputs:
      matrix: ${{ steps.set-matrix.outputs.matrix }}
    steps:
      - name: Prepare runner matrix
        id: set-matrix
        run: |
          echo '::set-output name=matrix::[["self-hosted", "A100"]]'

  Integration-Tests:
    needs: Runner-Preparation
    timeout-minutes: 240  # 4 hours
    runs-on: ${{ matrix.runner }}
    strategy:
      matrix:
        runner: ${{fromJson(needs.Runner-Preparation.outputs.matrix)}}
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Packages
        run: |
          ./.github/workflows/torch-inductor/scripts/install_torchinductor.sh torchbench
      - name: Environment
        run: |
          source /opt/torchinductor_venv/bin/activate
          ./.github/workflows/torch-inductor/scripts/install_triton.sh
      - name: Performance
        run: |
          ./.github/workflows/torch-inductor/scripts/run_torchinductor_perf.sh torchbench
      # Runs too long time
      #- name: Accuracy
      #  run: |
      #    ./.github/workflows/torch-inductor/scripts/run_torchinductor_acc.sh
